﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using SMO.Models;

namespace SMO.Models.SimplObject
{
    public class CashRepository
    {
        private SMO_LinQDataContext datacontent = new SMO_LinQDataContext();
        public IQueryable<Cash> GetAll()
        {
            return datacontent.Cashes;
        }

        public Cash GetByCashID(string id)
        {
            return datacontent.Cashes.SingleOrDefault(s => s.CashId.ToString().Trim() == id.Trim());
        }

        public IQueryable<Cash> GetByUserID(string id)
        {
            return datacontent.Cashes.Where(s => s.UserId.ToString().Trim() == id.Trim());
        }

        public Cash GetFirst()
        {
            return datacontent.Cashes.FirstOrDefault();
        }

        public void Add(Cash cash)
        {
            datacontent.Cashes.InsertOnSubmit(cash);
        }

        public void Delete(Cash cash)
        {
            datacontent.Cashes.DeleteOnSubmit(cash);
        }

        public void Save()
        {
            datacontent.SubmitChanges();
        } 
    }
}
